package com.only4play.user.web.resources;

import com.only4play.common.model.GeneralResponse;
import com.only4play.common.model.PageableRequest;
import com.only4play.user.model.dto.input.OrganizationEnterRequestDto;
import com.only4play.user.model.dto.output.OrganizationEnterResponseDto;
import com.only4play.user.model.dto.output.UserOrganizationalAccountDto;
import com.only4play.user.service.UserOrganizationalAccountService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liyuncong
 * @version 1.0
 * @file PermissionResource
 * @brief PermissionResource
 * @details PermissionResource
 * @date 2024/12/14
 * <p>
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2024/12/14                    liyuncong          Created
 */
@RestController
@RequestMapping(
    value = "/api/v1/permissions",
    produces = MediaType.APPLICATION_JSON_VALUE
)
@RequiredArgsConstructor
public class PermissionResource {

    @Autowired
    private UserOrganizationalAccountService accountService;

    @RequestMapping(
        method = RequestMethod.POST,
        path = ""
    )
    public GeneralResponse<OrganizationEnterResponseDto> enter(
        @RequestBody OrganizationEnterRequestDto requestDto
    ) {
        return GeneralResponse.of(
            accountService.enter(requestDto).orElse(null)
        );
    }

    public GeneralResponse<UserOrganizationalAccountDto> searchOrganizationalAccounts(
        @RequestParam(name = "keyword", required = false) String keyword,
        @NotNull PageableRequest pageRequest
    ) {
        return null;
    }
}
